package com.jj.act.battleserver;

import com.alibaba.fastjson.parser.ParserConfig;
import com.jj.net.kcp.KcpChannelManager;
import com.jj.net.tcp.TcpAccepterManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;

@ComponentScan("com.jj")
@EntityScan("com.jj")
@EnableJpaRepositories("com.jj")
@SpringBootApplication
@EnableScheduling
public class BattleserverApplication implements CommandLineRunner {
    private static Logger logger = LoggerFactory.getLogger(BattleserverApplication.class);

    @Autowired
    private TcpAccepterManager tcpAccepterManager;

    @Autowired
    private KcpChannelManager kcpChannelManager;

//    @Autowired
//    private TickerWorkerThread tickerWorkerThread;

	public static void main(String[] args) {
		SpringApplication.run(BattleserverApplication.class, args);
	}

	@Override
	public void run(String... strings) throws Exception {
        ParserConfig.getGlobalInstance().setAutoTypeSupport(true);

        tcpAccepterManager.start();

        //start kcp server
        kcpChannelManager.start();

        //start ticker worker
//        tickerWorkerThread.start();
	}
}
